<?php 
    namespace Mark\Component;
    use DateTime;
    use Mark\Component\AbstractComponent;
    
    class MarkAlbumComponent extends AbstractComponent {
        protected  $entity="Mark\\Entity\\MarkAlbum";
        
        
        function insert($object){
            $now = new DateTime("now");
            $object->createdAt = $now;
            $object->modifiedAt = $now;
            $this->em->persist($object);
            $this->em->flush();
        }
        
        
        function update($object){
            $now = new DateTime("now");
            $object->modifiedAt = $now;
            $this->em->persist($object);
            $this->em->flush();
        }
        
        
        function delete($id){
            $user = $this->em->find($this->entity, $id);
            $this->em->remove($user);
            $this->em->flush();
        }
        
        
        function get($id){
            return $this->em->find($this->entity, $id);
        }
        
        
        function listAll(){
            return $this->em->getRepository($this->entity)->findAll();
        }
        
        
        public function listByAlbum($idAlbum, $maxResult=null){
            return $this->em->getRepository($this->entity)->listByAlbum($idAlbum, $maxResult);
        }
        
        
    }
